- Article
- 2018-09-03
Начнем мы пожалуй с простого примера. Например сделать только себе двойной прыжок.
#include <amxmodx>
#include <amxmisc>
#include <engine>
new jumpnum[33] = 0
new bool:dojump[33] = false
public plugin_init()
{
register_plugin("MultiJump","1.1","Dedik")
register_cvar("amx_maxjumps1","1")
}
public client_putinserver(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_disconnect(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_PreThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
new nbut = get_user_button(id)
new obut = get_user_oldbutton(id)
if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
{
if(jumpnum[id] < get_cvar_num("amx_maxjumps1"))
{
dojump[id] = true
jumpnum[id]++
return PLUGIN_CONTINUE
}
}
if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
{
jumpnum[id] = 0
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public client_PostThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
if(dojump[id] == true)
{
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity)
velocity[2] = random_float(265.0,285.0)
entity_set_vector(id,EV_VEC_velocity,velocity)
dojump[id] = false
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
Добавим туда new name[32] и в функции client_PreThink узнаем все ники на сервере
#include <amxmodx>
#include <amxmisc>
#include <engine>
new jumpnum[33] = 0
new bool:dojump[33] = false
new name[32]
public plugin_init()
{
register_plugin("MultiJump","1.1","Dedik")
register_cvar("amx_maxjumps1","1")
}
public client_putinserver(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_disconnect(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_PreThink(id)
{
get_user_name(id, name, 31)
if(!is_user_alive(id)) return PLUGIN_CONTINUE
new nbut = get_user_button(id)
new obut = get_user_oldbutton(id)
if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
{
if(jumpnum[id] < get_cvar_num("amx_maxjumps1"))
{
dojump[id] = true
jumpnum[id]++
return PLUGIN_CONTINUE
}
}
if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
{
jumpnum[id] = 0
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public client_PostThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
if(dojump[id] == true)
{
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity)
velocity[2] = random_float(265.0,285.0)
entity_set_vector(id,EV_VEC_velocity,velocity)
dojump[id] = false
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
добавляем свой никИ получаем:
#include <amxmodx>
#include <amxmisc>
#include <engine>
new jumpnum[33] = 0
new bool:dojump[33] = false
new name[32]
public plugin_init()
{
register_plugin("MultiJump","1.1","Dedik")
register_cvar("amx_maxjumps1","1")
}
public client_putinserver(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_disconnect(id)
{
jumpnum[id] = 0
dojump[id] = false
}
public client_PreThink(id)
{
get_user_name(id, name, 31)
if(!is_user_alive(id)) return PLUGIN_CONTINUE
new nbut = get_user_button(id)
new obut = get_user_oldbutton(id)
if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP) && (equali(name, "123321")))
{
if(jumpnum[id] < get_cvar_num("amx_maxjumps1"))
{
dojump[id] = true
jumpnum[id]++
return PLUGIN_CONTINUE
}
}
if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
{
jumpnum[id] = 0
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public client_PostThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
if(dojump[id] == true)
{
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity)
velocity[2] = random_float(265.0,285.0)
entity_set_vector(id,EV_VEC_velocity,velocity)
dojump[id] = false
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
в кавычках писать свой никнапример: "123321" (ну как показано выше)
Таким вот образом мы сделали так чтобы эта функция работала на определенный ник и при этом не надо будет использовать для этого флаги доступа
ИЛИ
Мы можем сделать так чтобы у всех работала данная функция КРОМЕ игрока с этим ником
Поставив всего лишь ! перед (equali(name, "123321")
Получится как-то так !(equali(name, "123321")
Это был простой способ ограничить функцию по нику.
А теперь сделаем свой плагин только чуточку по сложнее.
Представим что у нас есть друг-задрот кс 1.6 и у него скоро ДР и вы хотите его оригинально поздравить на своем сервере ИЛИ просто выделить его из толпы игроков.
Ну типо приступим...
Для начала это приветствие и представление. Типо когда этот ваш друг зашел на сервер, то тут же появляется dhud сообщение всем (ну типо "НАРООООД,СЕГОДНЯ У НАШЕГО ВИНИПУХА ДЕНЬ РОЖДЕНИЯ! Поздравьте его как следует!")
Ну можно и еще какую нибудь музычку добавить и т.д.
#include <amxmodx>
#include <amxmisc>
new name[32]
public plugin_init()
{
register_plugin("днюха у винипуха", "1.0","XZ")
register_event("ResetHUD", "resetModel", "b")
}
public plugin_precache()
{
precache_generic("sound/dr_vinipyha.mp3")
precache_model("models/player/dr/dr.mdl")
}
public client_putinserver(id)
{
get_user_name(id, name, 31)
if(equali(name, "Vinipyx"))
{
set_dhudmessage(255, 0, 0, 0.45, 0.1, 1, 5.0, 8.0, 0.3, 0.5)
show_dhudmessage(0, "НАРООООД,СЕГОДНЯ У НАШЕГО ВИНИПУХА^n ДЕНЬ РОЖДЕНИЯ! Поздравьте его как следует!")
client_cmd(0, "mp3 play sound/dr_vinipyha.mp3")
color_print(id, "!t[!gBIO!t] С ДР !g%s!!!", name)
new flags = read_flags("abcdefghijklmnopqrstu")
set_user_flags(id, flags)
}
}
public resetModel(id, level, cid)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED
if(is_user_alive(id) && equali(name, "Vinipyx"))
{
cs_set_user_model(id, "dr")
}
else
{
cs_reset_user_model(id)
}
return PLUGIN_CONTINUE
}
stock color_print(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!n", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
Не знаю есть ли там ошибки... ну думаю должно работать =)Я думаю винипуху понравилось такое поздравление (знаете... вроде мелочь а приятно будет =) )
Ну а более серьезные задачи вы сами себе придумаете!
%25
Discount on all purchases
builds until September 16, 2024
Especially for you - Гость
![](https://vk.com/images/emoji/2764_2x.png)
Buy an assembly
![](http://www.tb-team.com/uploads/fotos/foto_9428.jpg)
[CS 1.6] Weapon Model - Ethereal Xmas
one of the best p90 models, we had on the server. ++
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Knife Model - Xmas Candy Axe
nice xmas model
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Weapon Model - White Railcannon Xmas
Nice model thanks
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Weapon Model - Royale Dragon M4a1
Nice model thanks
![](http://tb-team.com/uploads/fotos/foto_1.png)
[ZP] Zombie Class - Revenant Raving (Переделка Fire)
happy to hear that from you ! enjoy
ReHLDS (Reverse-engineered) - this is a new step forward that gives a second wind to our servers. ReHLDS works 2 times faster than HLDS.
AMXModX is a Metamod add-on that allows you to create new modifications for Half-Life in the Pawn language
Reunion is a continuation of Dproto for ReHLDS. This is a metamod plugin that allows you to log into the 47/48 Non-Steam server.
Revoice is a Metamod plugin that allows voice chat between non-steam and steam clients.
The new Metamod-r contains a huge number of performance optimizations and much cleaner code. The kernel was written using a JIT compiler.
Ultimate Unprecacher is a plugin for MetaMod, it works on the principle of disabling unnecessary resources on your server, thereby you can free up space for resources for your plugins, using this module you can get rid of error 512!
ReAuthCheck - this is a Metamod plugin that checks your players for validity, with this module for REHLDS you can protect your server from bots that constantly spam ads or simply clog up a slot on the server!
NetBufExtender or NBEX - This is a metamod plugin that expands the пїЅInternet bufferпїЅ: server and client buffers (not 100% guaranteed). Expands up to 64 kb. This means that players are less likely to be kicked with the error "Reliable channel overflowed"".
UINO пїЅ metamod plugin that allows you to remove unnecessary fields from userinfo(setinfo) when the engine passes it to other players on the server. This measure reduces the amount of data transferred and slightly reduces the chance of being kicked with "Reliable channel overflowed".